package joodin.impl.application.util;

import org.vaadin.artur.icepush.ICEPush;
import org.vaadin.cssinject.CSSInject;

import com.vaadin.Application;
import com.vaadin.ui.Window;

@SuppressWarnings("serial")
public abstract class ApplicationWrapper extends Application{

	private Window activeWindow;
	protected static ApplicationWrapper currentApplication;
	private static CSSInject injector = new CSSInject("");
	private static ICEPush pusher = new ICEPush();
	
	public static ApplicationWrapper getInstance(){
		return currentApplication;
	}
	
	public static CSSInject getCSSInjector(){
		return injector;
	}
	
	public Window getActiveWindow(){
		return activeWindow;
	}
	
	public static ICEPush getPusher(){
		return pusher;
	}

	@Override
	public void init() {
		// Create the main window we will be using in this application
		setTheme("runo");
//		setTheme("windowsXP-theme");
		activeWindow = new Window();
        activeWindow.setSizeFull(); 
        activeWindow.setBorder(Window.BORDER_MINIMAL);
        this.setMainWindow(activeWindow);
        activeWindow.addComponent(pusher);
        currentApplication = this;
        activeWindow.addComponent(injector);
        
       String textSize = ".v-app { background: #d0e2ec;}\n";
       
       injector.setValue(textSize);
       activeWindow.addStyleName("v-app");

        
        applicationInit();
	}

	public abstract void applicationInit();
		
}
